package net.ariel.myideablog.web.admin;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.ariel.myideablog.dao.IBlog;
import net.ariel.myideablog.dao.ICategory;
import net.ariel.myideablog.dao.ILink;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class AdminController extends MultiActionController {

	private String viewPage;
	private ICategory iCategory;
	private ILink iLink;
	private IBlog iBlog;
	
	public void setViewPage(String viewPage) {
		this.viewPage = viewPage;
	}
	
	public void setICategory(ICategory iCategory) {
		this.iCategory = iCategory;
	}
	
	public void setILink(ILink iLink) {
		this.iLink = iLink;
	}
	
	public void setIBlog(IBlog iBlog) {
		this.iBlog = iBlog;
	}
	
	public ModelAndView index(HttpServletRequest request, HttpServletResponse response) {
		int categoryNumber = iCategory.getCategoryNumber();
		int linkNumber = iLink.getLinkNumber();
		int blogNumber = iBlog.getBlogNumber();
		ModelAndView mav = new ModelAndView();
		mav.setViewName(viewPage);
		mav.addObject("categoryNumber", categoryNumber);
		mav.addObject("linkNumber", linkNumber);
		mav.addObject("blogNumber", blogNumber);
		return mav;
	}
}
